package com.taiyi.renaissancemall.ui.mine.team;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.taiyi.renaissancemall.R;
import com.taiyi.renaissancemall.Utils.RegexUtil;
import com.taiyi.renaissancemall.bean.CollectBean;
import com.taiyi.renaissancemall.bean.MyTeamListBean;

import java.util.List;

public class MyTeamAdapter extends BaseQuickAdapter<MyTeamListBean.TuanlistBean, BaseViewHolder> {
    public MyTeamAdapter(int layoutResId, @Nullable List<MyTeamListBean.TuanlistBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyTeamListBean.TuanlistBean item) {
        ImageView img = (ImageView) helper.getView(R.id.avatarIv);
        if (item.headimg != null && !"".equals(item.headimg)) {
            Glide.with(mContext).load(item.headimg).into(img);
        }
        String teamTel = RegexUtil.phoneNoHide(item.tel);
        helper.setText(R.id.userName, teamTel);
        String userLv = item.levelname + "会员";
        helper.setText(R.id.levelName, userLv);
        String bvNum = "";
        if ("0.0".equals(item.bvnum)) {
            bvNum = "0BV";
        } else {
            bvNum = item.bvnum + "BV";
        }
        helper.setText(R.id.bvNum, bvNum);
        ImageView iv_team_lv = helper.getView(R.id.iv_team_lv);

        if (item.rongname != null && !"".equals(item.rongname)) {
            if ("一星铂金".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.yixingbaijin);
            } else if ("二星铂金".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.erxingbaijin);
            } else if ("三星铂金".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.sanxingbaijin);
            } else if ("四星铂金".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.sixingbaijin);
            } else if ("五星铂金".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.wuxingbaijin);
            } else if ("钻石".equals(item.rongname)) {
                iv_team_lv.setImageResource(R.mipmap.zuanshihuiyuan);
            }
        } else {
            if (item.levelid == 1) {
                iv_team_lv.setImageResource(R.mipmap.putonghuiyuan);
            } else if (item.levelid == 2) {
                iv_team_lv.setImageResource(R.mipmap.jinkahuiyuan);
            } else if (item.levelid == 3) {
                iv_team_lv.setImageResource(R.mipmap.baijinhuiyuan);
            } else if (item.levelid == 4) {
                iv_team_lv.setImageResource(R.mipmap.zuanshihuiyuan);
            }
        }

    }
}
